package com.supper;

import com.supper.bean.AppBeanConfig;
import com.supper.bean.Calculator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.instrument.Instrumentation;
import java.util.LinkedHashMap;

/**
 * @author yutao
 * @since 2020/4/14 3:29 下午
 */
public class BeanTest {

    public static void premain(String agentOps, Instrumentation instrumentation) {
        System.out.println("====premain===方法执行====");
        System.out.println(agentOps);
    }

    public static void premain(String agentOps) {
        System.out.println("===premain===方法执行2===");
        System.out.println(agentOps);
    }

    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppBeanConfig.class);

        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }

        LinkedHashMap<String, Integer> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put("11", 11);

        System.out.println("=================" + linkedHashMap);

        Calculator calculator = applicationContext.getBean(Calculator.class);
        calculator.add(1, 2);
    }
}
